package com.redis;

import redis.clients.jedis.Jedis;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * 有序集合代碼測試
 * @author yi.yang
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2018/7/2912:49
 */
public class RedisClient {
    public static void main(String[] args) {

        Jedis jedis = new Jedis("192.168.2.104");
        System.out.println("连接成功");
    }

    public static void  initDate( Jedis jedis){
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        for(int hour = 1; hour<12;hour++ ) {
            calendar.set(Calendar.HOUR_OF_DAY, hour);
            for (int minute = 1; minute <= 60; minute++) {
                calendar.set(Calendar.MINUTE, minute);
                jedis.zadd("mytime",Double.valueOf(String.valueOf(calendar.getTime().getTime())),format.format(calendar.getTime()));
            }
        }
    }
    public static void runStatus() {
        Jedis jedis = new Jedis("192.168.2.104");
        System.out.println("连接成功");
        //查看服务是否运行
        System.out.println("服务正在运行: "+jedis.ping());
    }
}

